﻿@model CuongHanh.Models.Banner
@(Html.X()
          .FormPanel()
          .ID("BasicForm")
          .Region(Region.Center)
          .Layout(LayoutType.Column)
          .Border(false)
          .StyleSpec("background-color:white;")
          .Padding(10)
          .Items(form =>
                 {
                     form.Add(Html.X().HiddenFor(m => m.Id));
                     form.Add(Html.X().HiddenFor(m => m.BranchId));
                     form.Add(Html.X().HiddenFor(m => m.Image));
                     form.Add(Html.X().FileUploadField()
                             .ID("FileUploadField1")
                             .Width(300)
                             .EmptyText("chọn file ảnh upload")
                             .ButtonText("")
                             .Icon(Icon.ImageAdd));
                     form.Add(Html.X().Button()
                             .ID("SaveButton")
                             .Text("Lưu lại")
                             .DirectEvents(de =>
                                           {
                                               de.Click.Url = Url.Action("UploadClick");
                                               de.Click.ExtraParams.Add(new Parameter("productId",
                                                       Model + ""));
                                               de.Click.FormID = "fileUpload";
                                               de.Click.Before = @"if (!#{BasicForm}.getForm().isValid()) { return false; } Ext.Msg.wait('Uploading your photo...', 'Uploading');";
                                               de.Click.Failure = @"Ext.Msg.show({ 
                                                                                                                                            title   : 'Error', 
                                                                                                                                            msg     : 'Error during uploading', 
                                                                                                                                            minWidth: 200, 
                                                                                                                                            modal   : true, 
                                                                                                                                            icon    : Ext.Msg.ERROR, 
                                                                                                                                            buttons : Ext.Msg.OK 
                                                                                                                                        });";
                                           }));
                     form.Add(Html.X()
                             .Button()
                             .ID("btCancel")
                             .Text("Hủy")
                             .StyleSpec("margin-left:10px;")
                             .OnClientClick("App.wdModify.hide();")
                             );
                 }))